<?php

namespace App\Models;


use App\Service\Base\Model;

class CourseCycle extends Model
{

    // 广告管理
    protected $table = 'course_cycle';

    // 缓存字段，用于搜索绑定的字段
    protected $cacheFields = ['id', 'uid', 'course_id'];

    // {"id":"自编号","uid":"用户ID","course_id":"课程id","cycle":"课时周期（月周日）","number":"第几次（每月第几日，每周第几日，每日默认0）","start_time":"开始时间","end_time":"结束时间","ctime":"注册时间","mtime":"更新时间"}


    // array ( 'id' => '$this->getData("id")', 'uid' => '$this->getData("uid")', 'course_id' => '$this->getData("course_id")', 'cycle' => '$this->getData("cycle")', 'number' => '$this->getData("number")', 'start_time' => '$this->getData("start_time")', 'end_time' => '$this->getData("end_time")', 'ctime' => '$this->getData("ctime")', 'mtime' => '$this->getData("mtime")', )


    // $id = $this->getData("id"); $uid = $this->getData("uid"); $course_id = $this->getData("course_id"); $cycle = $this->getData("cycle"); $number = $this->getData("number"); $start_time = $this->getData("start_time"); $end_time = $this->getData("end_time"); $ctime = $this->getData("ctime"); $mtime = $this->getData("mtime");

    // 获取所有的周期
    public function getCycles()
    {
        return ['week' => '每周', 'month' => '每月'];
    }

    // 定义验证操作
    public function rules()
    {

        $add = [
            'uid' => 'required',
        ];

        $edit = [
        ];

        $info = [
        ];


        $rule = [
            'course_id'  => 'required',
            'cycle'      => 'required',
            'start_time' => 'required',
            //'end_time'   => 'required',
            //'number'     => 'required',
            //'hour'       => 'required',
            //'minute'     => 'required',
            //'status' => ['in:-1,0,1,2'],
        ];


        $msg = [
            'id'         => '自编号',
            'uid'        => '用户ID',
            'course_id'  => '课程id',
            'cycle'      => '课时周期（月周日）',
            'number'     => '第几次（每月第几日，每周第几日，每日默认0）',  // week:1-7 month:1-31
            'start_time' => '开始时间',
            'end_time'   => '结束时间',
            'hour'       => '小时：0-24',
            'minute'     => '时间：0-60',
            'ctime'      => '注册时间',
            'mtime'      => '更新时间',
        ];

        return ['rule' => $rule, 'msg' => $msg, 'add' => $add];
    }
}
